<?php
require_once("Config.php");
$messageFlag = '0';
$showXContent = 'theIntro_';
if($_GET['action']=='saveIntro'){
  $sql = "update news set content='".$_POST['introContent']."' where newsType=3 and title='events_intro'";
  if(mysql_query($sql)){
    $sessionMessage ="Save content success!";
  }else{
    $sessionMessage = 'Save conent failure!';
  }
  $messageFlag='1';
}

if($_GET['action']=='saveSemiPrivate'){
  $sql = "update news set content='".$_POST['semiPrivateContent']."' where newsType=3 and title='events_semiPrivate'";
  if(mysql_query($sql)){
    $sessionMessage ="Save  content success!";
  }else{
    $sessionMessage = 'Save conent failure!';
  }
  $messageFlag='1';
}


if($_GET['action']=='savePrivate'){
  $sql = "update news set content='".$_POST['privateContent']."' where newsType=3 and title='events_private'";
  if(mysql_query($sql)){
    $sessionMessage ="Save  content success!";
  }else{
    $sessionMessage = 'Save  conent failure!';
  }
  $messageFlag='1';
}
if(isset($_GET['showXContent'])){
  $showXContent = $_GET['showXContent'];
}



$sql = "Select * From news where newsType=3";
$result = mysql_query($sql);
if(!$result){
  echo 'Errow account when query the database.';
  exit();
}
while($row = mysql_fetch_array($result)){
      
    if($row['title']=='events_intro'){
      $events_intro = $row['content'];
    }  
    if($row['title']=='events_semiPrivate'){
      $events_semiPrivate = $row['content'];
    }
    if($row['title']=='events_private'){
      
      $events_private = $row['content'];
    }
    
  
}

?>
<html>
  <head>
    <title>
      Add User !
    </title>
    <link href="css/admin-common.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="../js/jquery.js">
    </script>
   
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    
  </head>
  <body>
  <input type="hidden" name='messageFlag' id='messageFlag' value='<?php echo $messageFlag ?>'/>
  <input type="hidden" name="showXContent" id="showXContent" value="<?php echo $showXContent?>"
    <h3>Content Management : About Us</h3>
    <hr/>
    <!--Here is the message from server when page load-->
    <div id="sessionMessage">
      <?php echo $sessionMessage?>
    </div>
    <!--Session Message End-->
    
      <p class="subLinks">
      <label>
        <Strong><a href="#" id='theIntro'><span>Intro</span></a></Strong>
      </label> |
     <label>
        <Strong><a href="#" id='theSemiPrivate'><span>Semi-Private</span></a></Strong>
      </label> |
      <label>
        <Strong><a href="#" id='thePrivate'><span>Private</span></a></Strong>
      </label>      
    </p>
    
    
    <!--Add User Form-->
    <form action="?action=saveIntro&showXContent=theIntro" method="post" id="theIntro_" name='theIntro_'>
    <strong>Introduction of menus goes here:</strong>
      <textarea class="ckeditor" cols="80" id="introContent" name="introContent" rows="20"><?php echo $events_intro ?></textarea>
      <p>
        <label>
          <span>&nbsp;</span>
          <button class="btn btn-style-1" type="submit">
            <b><b>Save</b></b>
          </button>
        </label>
      </p>
    </form>
    
    <form action="?action=saveCocktail&showXContent=theSemiPrivate_" method="post" id="theSemiPrivate_" name='theSemiPrivate_'>
    <strong>Cocktail Menu:</strong>  
      <textarea class="ckeditor" cols="80" id="semiPrivateContent" name="semiPrivateContent" rows="20"><?php echo $events_semiPrivate ?></textarea>
      <p>
        <label>
          <span>&nbsp;</span>
          <button class="btn btn-style-1" type="submit">
            <b><b>Save</b></b>
          </button>
        </label>
      </p>
    </form>
    
    <form action="?action=saveWhisky&showXContent=thePrivate_" method="post" id="thePrivate_" name="thePrivate_">
    <strong>Whisky Menu:</strong> 
      <textarea class="ckeditor" cols="80" id="privateContent" name="privateContent" rows="20"><?php echo $events_private ?></textarea>
      <p>
        <label>
          <span>&nbsp;</span>
          <button class="btn btn-style-1" type="submit">
            <b><b>Save</b></b>
          </button>
        </label>
      </p>
    </form>
    
 
  </body>
  <script type="text/javascript">
    var app={
      init: function() {
     app.showTheContent($('#showXContent').val());
      
    
      
       /* $('form').css('display','none');
        $('#theIntro_').css('display','');
        $($('.subLinks label a span')[0]).addClass('currentItem');*/
        $($('.subLinks label a')).bind('click', function() {
       
          var items = $('.subLinks label a span');

          for(var i=0;i<items.length;i++) {
            if($($(items[i]).parent()).attr('id')==$(this).attr('id')) {
              app.showTheContent($(this).attr('id')+'_');
              /*$(items[i]).addClass('currentItem');
              $('form').css('display','none');
              $('#'+$($(items[i]).parent()).attr('id')+'_').css('display','');*/
            }
          }
          return;
        })

      },
      showTheContent:function(theFormId){ 
      $('.subLinks label a span').removeClass('currentItem');
          $('form').css('display','none');
          $('#'+theFormId).css('display','');
        $(('#'+theFormId.split('_')[0]+' span')).addClass('currentItem');
      }

    }
  </script>
   <script type="text/javascript" src="js/common.js">
    </script>
</html>
